package com.project.controller;

import com.project.bean.BuyerCarBean;
import com.project.bean.GoodsBean;
import com.project.service.IBuyerCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("buyerCar")
public class BuyerCarController {
    @Autowired
    private IBuyerCarService service;
    @RequestMapping("findByUserId")
    public List<BuyerCarBean> findByUserId(Integer userId){
        return service.findByUserId(userId);
    }
@RequestMapping("add")
    public String add(String option, Integer number, String name, String brand, String genre,
                      Integer price, Integer sellPrice, Integer num,String img, Integer nums, Integer userId){
        GoodsBean goods = new GoodsBean(number,name,brand,genre,price,sellPrice,num,img);
        service.add(option,goods,nums,userId);
        return "ok";
    }
@RequestMapping("del")
    public String del(Integer buyCarId){
        service.del(buyCarId);
        return "ok";
    }
@RequestMapping("update")
    public String update(Integer byCarId,Integer num){
        service.update(byCarId,num);
        return "ok";
    }
}
